import 'package:flutter/material.dart';

class Widget_GridView_Normal_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_GridView_Normal_State_Page();
  }
}

class Widget_GridView_Normal_State_Page
    extends State<Widget_GridView_Normal_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("GridView 构造函数方式"),
        ),
        body: GridView(
          //SliverGridDelegateWithFixedCrossAxisCount可以直接指定每行（列）显示多少个Item，SliverGridDelegateWithMaxCrossAxisExtent会根据GridView的宽度和你设置的每个的宽度来自动计算没行显示多少个Item
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2, //每行2个
            mainAxisSpacing: 10.0, //主轴方向间距
            crossAxisSpacing: 10.0, //水平方向间距
            childAspectRatio: 1.0, //纵轴缩放比例
          ),
          children: <Widget>[
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
            Container(
              color: Color(0xfff1f1f1),
              child: Text("aaaaaaaaaaaaaaaa"),
            ),
          ],
        ),
      ),
    );
  }
}

/**
    GridView({
    Key key,
    Axis scrollDirection = Axis.vertical,//滚动方向
    bool reverse = false,//是否反向显示数据
    ScrollController controller,
    bool primary,
    ScrollPhysics physics,//物理滚动
    bool shrinkWrap = false,
    EdgeInsetsGeometry padding,
    @required this.gridDelegate,
    bool addAutomaticKeepAlives = true,//自动保存视图缓存
    bool addRepaintBoundaries = true,//添加重绘边界
    bool addSemanticIndexes = true,
    double cacheExtent,
    List<Widget> children = const <Widget>[],
    int semanticChildCount,
    })
 */

/**
    const SliverGridDelegateWithFixedCrossAxisCount({
    @required this.crossAxisCount,//每行几个
    this.mainAxisSpacing = 0.0,//主轴方向间距
    this.crossAxisSpacing = 0.0,//纵轴方向间距
    this.childAspectRatio = 1.0,//主轴纵轴缩放比例
    })
 */
